#include "DElementDelegate.h"
#include "delement.h"

DElementDelegate* DElementDelegate::_instance = 0;

DElementDelegate* DElementDelegate::instance()
{
	if (_instance == 0) {
		_instance = new DElementDelegate;
	}
	return _instance;
}

void DElementDelegate::registerDElement(DElement* de)
{
	if (de->kind() == kActor)
		mActors[de->className()] = de;
	else if (de->kind() == kRouter) 
		mRouters[de->className()] = de;
	else if (de->kind() == kPool)
		mPools[de->className()] = de;
	else
		mComposites[de->className()] =de;
}

DElement* DElementDelegate::find(const QString& kind, const QString& className)
{
	if (kind == kActor) 
		return mActors[className];
	else if (kind == kRouter)
		return mRouters[className];
	else if (kind == kPool)
		return mPools[className];
	else if (kind == kComposite)
		return mComposites[className];
	else
		return NULL;
}
